package com.gky.gkytemplate.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gky.gkytemplate.pojo.dto.team.TeamQueryRequest;
import com.gky.gkytemplate.pojo.entity.Team;
import com.gky.gkytemplate.pojo.entity.User;
import com.gky.gkytemplate.service.TeamService;
import com.gky.gkytemplate.mapper.TeamMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
* @author gky
* @description 针对表【team(球队)】的数据库操作Service实现
* @createDate 2024-10-30 16:05:14
*/
@Service
@Slf4j
public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team>
    implements TeamService{

    @Override
    public Page<Team> listPage(TeamQueryRequest teamQueryRequest) {
        int current = teamQueryRequest.getCurrent();
        int pageSize = teamQueryRequest.getPageSize();
        Page<Team> page = new Page<>(current, pageSize);
        LambdaQueryWrapper<Team> teamLambdaQueryWrapper = new LambdaQueryWrapper<>();
        //球队名称
        if (StringUtils.isNotBlank(teamQueryRequest.getTeamName())) {
            teamLambdaQueryWrapper.eq(Team::getTeamName,teamQueryRequest.getTeamName());
        }
        //球队位置
        if (StringUtils.isNotBlank(teamQueryRequest.getLocation())) {
            teamLambdaQueryWrapper.eq(Team::getLocation,teamQueryRequest.getLocation());
        }
        //球队总冠军数量
        if (StringUtils.isNotBlank(teamQueryRequest.getChampionNums().toString())) {
            teamLambdaQueryWrapper.eq(Team::getChampionNums,teamQueryRequest.getChampionNums());
        }
        Page<Team> teamPage = this.baseMapper.selectPage(page, teamLambdaQueryWrapper);
        log.info("用户分页结果:{}", teamPage.toString());
        return teamPage;
    }
}




